<template>
  <div class="wrap">
    <el-date-picker
      :editable="false"
      v-model="dateValue"
      type="date"
      value-format="yyyy-MM-dd"
      :picker-options="pickerOptions"
      placeholder="选择日期"
      @change="dateChange">
    </el-date-picker>
     <el-select v-model="productId" placeholder="产品" style="width:120px;" @change="productChange">
            <el-option
            v-for="item in productNameOption"
            :key="item.value"
            :label="item.label"
            :value="item.value">
            </el-option>
        </el-select>
      <el-button icon="el-icon-refresh" @click="refreshClick" style="margin-left:20px;">刷新</el-button>

    
    <el-table
      class="table"
      border fit highlight-current-row
      v-loading="loading"
      element-loading-text="加载中"
      element-loading-spinner="el-icon-loading"
      :data="tableData"
      style="width: 100%">
      <el-table-column
          align="center"
          prop="phoneNum"
          label="用户手机号码">
      </el-table-column>
     
      <el-table-column
          align="center"
          prop="channelName"
          label="渠道来源">
      </el-table-column>
      <el-table-column
          align="center"
          prop="count"
          label="截图次数">
      </el-table-column>
     
      <el-table-column
          align="center"
          prop="position"
          label="截图页面">
      </el-table-column>

      <el-table-column
          align="center"
          prop="createTime"
          label="日期">
           <template slot-scope="scope">
            <p> {{_mapping.date_format2(scope.row.createTime)}}</p>
          </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="pagination"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="query.pageNum"
      :page-size="query.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="totalNum">
    </el-pagination>
  </div>
</template>
<script>
import _base from '@/services/base.js'
import _jpCheck from '@/services/jpCheck.js'
import _mapping from '@/utils/_mapping.js'
export default {
  data(){
    return {
      loading: false,
      productNameOption: [],
      tableData: [{
       
      }],
      dateValue:'',
      productId:'',
      query: {
        pageSize: 30,
        pageNum: 1
      },
      totalNum: 0,
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        }
      }
    }
  },
  methods: {
    handleSizeChange(val) {
      this.query.pageSize = val
      this.getAppCheckJPList()
    },
    dateChange(val){
      this.getAppCheckJPList()
    },
    handleCurrentChange(val) {
      this.query.pageNum = val
      this.getAppCheckJPList()
    },
    // 刷新按钮
    refreshClick(){
      this.getAppCheckJPList()
    },  // 获取产品下啦
    getProductList(){
        _base.getProductList()
        .then(res => {
            console.log('res', res.data)
            if(res.data && res.data.length){
                res.data.map(json => {
                    let item = {}
                    item.value = json.id
                    item.label = json.name
                    this.productNameOption.push(item)
                })
            }
        })
    },
    getAppCheckJPList(){
      let params = {
        "pageNum": this.query.pageNum,
        "pageSize": this.query.pageSize,
        "productId": this.productId,
        "searchDate":this.dateValue
      }
      _jpCheck.getAppCheckJPList(params)
      .then(res => {
        this.tableData = res.data.list
        this.totalNum = res.data.total
      })
    },
      // 产品切换
    productChange(item){
        console.log('productId', this.productId)
        this.getSettleMentList()
    }
    
    
  },
  created(){
    this.dateValue = this._mapping.date_format2(new Date())
    this.getProductList()
    this.getAppCheckJPList()

  }
}
</script>
<style lang="scss" scoped>
.wrap{
  .table{
    margin-top: 10px;
    margin-bottom: 25px;
  }
}
</style>